﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ToggleItem : ListToggleItem
{
    public Image icon;

    public Color darkColor;
    public Color brightColor;

    public override void Awake()
    {
        base.Awake();

        ShowDark();
    }

    public void ShowBright()
    {
        if(icon)
            this.icon.color = brightColor;
        this.titleText.color = brightColor;
        var outline = titleText.GetComponent<Outline>();
        if (outline)
            outline.effectColor = brightColor;
    }

    public void ShowDark()
    {
        if (icon)
            this.icon.color = darkColor;
        this.titleText.color = darkColor;
        var outline = titleText.GetComponent<Outline>();
        if (outline)
            outline.effectColor = darkColor;
    }

    protected override void _OnToggleValueChange(bool isOn)
    {
        base._OnToggleValueChange(isOn);

        //GameDebug.Log($"MainPanelToggleItem  _OnToggleValueChange:{isOn}");

        if (isOn)
        {
            ShowBright();
        }
        else
        {
            ShowDark();
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
